//动态封装url
layui.extend({
    http_proxy:'../myModules/http_proxy'
}).define(['setter','http_proxy'],function(exports) {
    'use strict';
    var $ = layui.$;
    var setter = layui.setter;
    var http_proxy = layui.http_proxy;

    var token = layui.data(setter.tableName).user_token;

    // var apiWhiteList = layui.setter.apiWhiteList;

    var req = function(settings){

        //白名单：跳转至某些页面，或者调取某些接口时，不需要进行token校验
        // var resultList = apiWhiteList.filter(function(x){
        //     return x === (url.indexOf('?') !== -1 ? url.substr(0,url.indexOf('?')) : url);
        // });

        // if(resultList.length === 0){
        //     if(token == null){
        //         parent.location.href = '/Layui-Admin-std/src/views/user/login.html';
        //     }
        // }

        //将本地的token添加到请求中
        settings.data = settings.data || {};
        settings.data.token = token;
        settings.url = http_proxy(settings.url);
        settings.type = settings.type || 'post';

        return $.ajax(settings);

    }
    exports('my_send', req);
});

